怎么获得<select>下文本内容,不是value值?

来源:百度知道 编辑:UC知道 时间:2024/06/17 08:19:30

<html>
<head>
<script language="javascript">
function func(obj){
alert(obj.options[obj.selectedIndex].innerText);
}
</script>
<title>test</title>
</head>
<body>
<select name="select1" onchange="func(this);">
<option value="1">一</option>
<option value="2">二</option>
<option value="3">三</option>
<option value="4">四</option>
</select>
</body>
</html>

document.all.select1.text

<html>
<body>
<script language=JavaScript>
function getText() {
var myindex=document.myform.testselect.selectedIndex;
document.myform.textshow.value=document.myform.testselect.options[myindex].text;

}
</script>
<form name="myfo